package com.zmx.common.common.config.shardingsphere;

import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;

import java.util.Collection;
import java.util.Date;

/**
 * @Description: 自定义分表 根据时间分片 年+月 格式：tablename_year_month
 * @ClassName: TableShardingAlgorithm
 * @Author zhaomxr
 * @Date 2021-12-08 16:19
 */
public class TableByDateOfYearMonthShardingAlgorithm extends TableByDateShardingAlgorithm implements PreciseShardingAlgorithm<Date> {

    @Override
    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Date> preciseShardingValue) {
        return getTable(availableTargetNames, preciseShardingValue, ShardingDateTypeEnum.YEAR_MOBTH);
    }
}
